<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>jsSip</title>
		<link rel="stylesheet" type="text/css" href="mainPhone.css" />
	</head>

	<body>
		<div id="mianBody">
			<div class="statusBar">
				<span>状态：</span><span id="regestStatus">未注册</span><span style="margin-left: 100px;" id="connectStatus">未通话</span>
			</div>
			<!--拨号显示区-->
			<div class="controls">
				<div class="dial-buttons">
					<div class="row">
						<span>号码：</span><input class="inputss" type="text" name="" value="" placeholder="请输入注册号码" id="JsSipPhoneNumber" />
					</div>
					<div class="row">
            		<span>IP：</span><input class="inputss" type="text" name=""  value="" placeholder="请输入IP地址" id="JsSipgetIp"/>
            		
            	</div>
					<div class="row">
						<span>PassWord：</span><input class="inputss" type="password" name="" value="" placeholder="请输入密码" id="JsSipgetPassWord" />
						<button onclick="GetInputValue()" class="registedBtn" title="注册">注册</button>
						<button onclick="unregisted()" class="registedBtn"   title="注销">注销</button>
					</div>
					<div class="row">
						<!--<span>呼叫：</span>--><input type="text" class="destination" value="" id="JsSip_callPhone" placeholder="请输入呼叫号码" />
						<button class="button call" onclick="toCall()" id="voiceCall"  title="语音通话">语音通话</button>
						
						<button class="button call" onclick="videoCall()" id="VideoCall" title="视频通话">视频通话</button>
						<!--<button class="button Hang" onclick="hangUpPhone()">挂断</button>-->
					</div>
					
					<div class="row">
						<div style="width: 230px;margin: 0 auto;margin-top: 20px;">
							<button class="button Hang" onclick="huangUp()" id="hangUpBtn" title="挂断">挂断</button>
						<!--<button class="button ansWer" onclick="ansWerPhone()" id="ansWerBtn">语音接听</button>-->
						<!--<button class="button " onclick="VideoAnswer()" id="ansWerBtn">视频接听</button>-->
						</div>
					</div>
					
				</div>
			</div>
			<!--视频区-->
		<div id="webcam">
			<video id="remoteView" autoplay></video>
			<div id="selfViewWap">
				<video id="selfView" autoplay></video>
			</div>
		</div>
		</div>
		<script src="https://webrtc.github.io/adapter/adapter-latest.js"></script>
		<script src="myjs/jssip.js" type="text/javascript" charset="utf-8"></script>
		<script src="myjs/main.js" type="text/javascript" charset="utf-8"></script>
		<script type="text/javascript">
			var myWebRtc =new MyWebrtc();
			//注册
			function GetInputValue () {
				var JsNumber= document.getElementById('JsSipPhoneNumber').value;
				var JsSipgetIp = document.getElementById('JsSipgetIp').value;
				var JsSipgetPassWord = document.getElementById('JsSipgetPassWord').value;
				var remoteVideo = document.getElementById('remoteView');
				var Registerstate = document.getElementById("regestStatus");
				var Callstate = document.getElementById("connectStatus");
				//调用注册方法
				myWebRtc.jssipAgent(JsNumber,JsSipgetIp,JsSipgetPassWord,remoteVideo,Registerstate,Callstate);
			}
			//注销
			function unregisted () {
				//取消注册
				myWebRtc.JsSip_clearRegested ();
			}
			//语音通话
			function toCall () {
				var callPhone = document.getElementById('JsSip_callPhone').value;
				//调用语音通话方法
				var isVoice = true;
				myWebRtc.JsSip_VoiceCall(callPhone,isVoice);
			}
			//视频通话
			function videoCall () {
				var callPhone = document.getElementById('JsSip_callPhone').value;
				var isVoice = false;
				//调用视频通话方法
				myWebRtc.JsSip_VideoCall(callPhone,isVoice);
				//调用本地视频接口
				myWebRtc.getlocalVideo();
			}
			//挂断
			function huangUp () {
				//调用挂断方法
				myWebRtc.JsSip_hangUpPhone();
			}
			//语音接听
			function ansWerPhone() {
				//调用语音接听方法
				myWebRtc.VoiceAnsWter();
			}
			//视频接听
			function VideoAnswer () {
				//调用视频接听方法
				myWebRtc.VideoAnsWter();
			}
			//获取注册状态
			function getRegistS () {
				//注册状态
				console.log(myWebRtc.getRegisterState())
				//通话状态
				console.log(myWebRtc.callPoneState());
			}
			
		</script>
	</body>

</html>